using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Data;
using Crosland.Framework.DataHelper;
using Crosland.Framework.Base;
using Crosland.Offline.Core;
using Crosland.Offline.Data.Helper;

namespace Crosland.Offline.Data.Dao
{
    public class VehiculoDao : DaoBase
    {
        public VehiculoDao(string strConn) : base(strConn)
        {
        }

        VehiculoHelper helper = new VehiculoHelper();

        public List<Vehiculo> GetByCriteria(string matnr, string zzcolor_desc, string vhcle, string sdsta, string avail)
        {
            List<Vehiculo> entitys = new List<Vehiculo>();
            DbCommand command = dbProvider.GetStoredProcCommand("USP_BUSQUEDA_STOCK");
            dbProvider.AddInParameter(command, helper.Matnr, DbType.String, matnr);
            dbProvider.AddInParameter(command, helper.ZzcolorDesc, DbType.String, zzcolor_desc);
            dbProvider.AddInParameter(command, helper.Vhcle, DbType.String, vhcle);
            dbProvider.AddInParameter(command, helper.Sdsta, DbType.String, sdsta);
            dbProvider.AddInParameter(command, helper.Avail, DbType.String, avail);

            using (IDataReader dr = dbProvider.ExecuteReader(command))
            {
                while (dr.Read())
                {
                    entitys.Add(helper.Create(dr));
                }
            }

            return entitys;
        }
    }
}
